package com.zsj.service_oss.controller;


import com.zsj.common_util.R;
import com.zsj.service_oss.service.OssService;
import jdk.jfr.ContentType;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/upload/fileoss")
@CrossOrigin
@Slf4j
public class OssController {

    @Autowired
    private OssService ossService;


    @PostMapping("/upAvatar")
    public R uploadAvatar(MultipartFile file) {
        String url = ossService.uploadFileAvatar(file);
        return R.ok().message("上传成功").data("url", url);
    }

    @PostMapping("/upGoodsImage")
    public R uploadGoodsImage(@RequestParam("file") MultipartFile file) {
        String url = ossService.uploadFileGoodsImage(file);
        return R.ok().message("上传成功").data("url", url);
    }

}
